//
//  BaseViewController.m
//  genericFramework
//
//  Created by 谷丰 on 2025/3/24.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController
-(UIView *)BaseNavBarView{
    if (!_BaseNavBarView) {
        _BaseNavBarView =[[UIView alloc]init];
        _BaseNavBarView.backgroundColor= rgba(255, 255, 255, 1);
        [self.view addSubview:_BaseNavBarView];
    }
    return _BaseNavBarView;
}
-(UIImageView * )BaseNavImageView{
    if (!_BaseNavImageView) {
        _BaseNavImageView=[[UIImageView alloc]init];
        _BaseNavImageView.backgroundColor=[UIColor clearColor];
        [self.BaseNavBarView addSubview:_BaseNavImageView];
    }
    return _BaseNavImageView;
    
}
-(UIImageView *)TopTitleImage{
    if (!_TopTitleImage) {
           _TopTitleImage=[[UIImageView alloc]init];
           [self.BaseNavBarView addSubview:_TopTitleImage];
       }
       return _TopTitleImage;
}
-(UILabel *)TopTitleLabel{
    if (!_TopTitleLabel) {
        _TopTitleLabel =[[UILabel alloc]init];
        _TopTitleLabel.textColor=rgba(255, 255, 255, 1);
        _TopTitleLabel.font =[UIFont boldSystemFontOfSize:18];
        _TopTitleLabel.textAlignment=NSTextAlignmentCenter;
        _TopTitleLabel.numberOfLines=0;
        [self.BaseNavBarView addSubview:_TopTitleLabel];
    }
    return _TopTitleLabel;
}
-(UIButton *)BaseBackButton{
    if (!_BaseBackButton) {
        _BaseBackButton =[[UIButton alloc]init];
        [_BaseBackButton setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
        [_BaseBackButton setImage:[UIImage imageNamed:@"icon_返回 拷贝 3(1)"] forState:UIControlStateNormal];
        [_BaseBackButton addTarget:self action:@selector(BackPress) forControlEvents:UIControlEventTouchUpInside];
        [self.BaseNavBarView addSubview:_BaseBackButton];
    }
    
    return _BaseBackButton;
}
-(UIButton *)BaseRightButton{
    if (!_BaseRightButton) {
        _BaseRightButton =[[UIButton alloc]init];
        [_BaseRightButton setTitleColor:rgba(51, 51, 51, 1) forState:UIControlStateNormal];
        [self.BaseNavBarView addSubview:_BaseRightButton];
    }
    return _BaseRightButton;
}
-(void)BackPress{
    
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:NO];
   
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=rgba(255, 255, 255, 1);
    [self setNeedsStatusBarAppearanceUpdate];
    self.BasePage=1;
    self.MjFooter = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
         //Call this Block When enter the refresh status automatically
        [self MjFooterTouchBlock];
     }];
    self.MjHeader = [MJRefreshGifHeader headerWithRefreshingBlock:^{
         //Call this Block When enter the refresh status automatically
        [self MjHeaderTouchBlock];
     }];
    // Do any additional setup after loading the view.
}
-(void)MjFooterTouchBlock{
    
}
-(void)MjHeaderTouchBlock{
    
}
-(void)CompositionNavBarHidden:(BOOL)hidden andHiddenBackButton:(BOOL)flag withTitle:(NSString *)titile{
    self.BaseNavBarView.frame=CGRectMake(0, 0, SCREEN_WIDTH, NAVIGATION_BAR_HEIGHT);
    self.BaseNavImageView.frame=CGRectMake(0, 0, SCREEN_WIDTH, NAVIGATION_BAR_HEIGHT);
    self.TopTitleImage.frame=CGRectMake(SCREEN_WIDTH/2-50, STATUS_BAR_HEIGHT, 100, 44);
    self.TopTitleLabel.frame=CGRectMake(55, STATUS_BAR_HEIGHT, SCREEN_WIDTH-110, 44);
    self.BaseBackButton.frame=CGRectMake(0, STATUS_BAR_HEIGHT, 55, 44);
    self.BaseRightButton.frame=CGRectMake(SCREEN_WIDTH-55, STATUS_BAR_HEIGHT, 55, 44);
    self.BaseNavBarView.hidden=hidden;
    self.BaseBackButton.hidden=flag;
    self.TopTitleLabel.text= titile;
    
}
-(void)ShowProgress{
    UIImage * image1 = [UIImage imageWithGIFNamed:@"loading"];
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
    [SVProgressHUD setInfoImage:image1];
    [SVProgressHUD setMinimumDismissTimeInterval:30];
    [SVProgressHUD showImage:image1 status:nil];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeBlack];
    [SVProgressHUD setBackgroundColor:rgba(0, 0, 0, 0.2)];
    
}
-(void)HiddenProgress{
    [SVProgressHUD dismiss];
}
//显示文字提示
- (void)ShowTextString:(NSString *)text  andWithTime:(NSInteger )time dissmess:(void (^)(id responseObject))success{
    if ([text isEqualToString:@""]) {
      }else{
      [SVProgressHUD showImage:[UIImage imageNamed:@""] status:text];
      [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
      [SVProgressHUD setDefaultStyle:SVProgressHUDStyleLight];
      [SVProgressHUD dismissWithDelay:time completion:^{
          success(@"1");
      }];
      }
}

-(UIStatusBarStyle)preferredStatusBarStyle

{
     return UIStatusBarStyleLightContent;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
